<?php
class BuyorderinfoController extends BuynodeController {
	
	public function remove() {
		$rs = self::getBuyOrderInfoService ()->removeGoodsById ( $this->_user_global, $_POST ['id'] );
		$this->sendNotice ( $rs ['message'], $rs ['data'], $rs ['status'] );
	}
	
	public function save() {
		$rs = self::getBuyOrderInfoService ()->setGoodsById ( $this->_user_global, $_POST ['key'], $_POST ['value'], $_POST ['id'] );
		$this->sendNotice ( $rs ['message'], $rs ['data'], $rs ['status'] );
	
	}
	
	public function add() {
		$rs = self::getBuyOrderInfoService ()->append ( $this->_user_global, $_POST ['goods_name'], $_POST ['num'], $_POST ['orderno'] );
		$this->sendNotice ( $rs ['message'], $rs ['data'], $rs ['status'] );
	}
	
	//更新快照
	public function snapshot() {
		$rs = self::getBuyOrderInfoService ()->saveSnapshot ( $_POST ['snapshot'], $_POST ['id'] );
		$this->sendNotice ( $rs ['message'], $rs ['data'], $rs ['status'] );
	
	}
	
	//打印订单
	public function p() {
		self::getBuyOrderInfoService ()->addLog ( $_POST ['orderid'], $this->_user_global ['real_name'], "打印订单" );
	}
	
	//编辑订单
	public function edit() {
		$rs = self::getBuyOrderInfoService ()->getOrderGoods ( $_GET ['sno'], $this->_user_global );
		$this->view ()->assign ( 'goods', $rs ['data'] );
		$this->view ()->assign ( 'log', $rs ['log'] );
		$this->view ()->assign ( 'order', $rs ['order'] );
		$this->view ()->assign ( 'shr', $rs ['shr'] );
		$this->view ()->display ( "file:buy/order_edit.tpl" );
	}
	//订单明细
	public function detail() {
		$rs = self::getBuyOrderInfoService ()->getOrderGoods ( $_GET ['sno'], $this->_user_global );
		$this->view ()->assign ( 'goods', $rs ['data'] );
		$this->view ()->assign ( 'order', $rs ['order'] );
		$this->view ()->assign ( 'shr', $rs ['shr'] );
		
		$this->view ()->display ( "file:buy/detail.tpl" );
	}
	
	public static function getBuyOrderInfoService() {
		return new BuyOrderInfoService ();
	}
}